Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

passport-oauth1

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

passport-oauth1

OAuth 1.0 authentication strategy for Passport.

  • 1.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
214K
decreased by-1.49%
Maintainers
1
Weekly downloads
 
Created

What is passport-oauth1?

The `passport-oauth1` package is a Passport strategy for authenticating with OAuth 1.0a providers. It allows applications to authenticate users using OAuth 1.0a, a protocol for authorization that enables third-party applications to obtain limited access to a user's resources without exposing their credentials.

What are passport-oauth1's main functionalities?

OAuth 1.0a Authentication

This feature allows you to set up OAuth 1.0a authentication in your application. The code sample demonstrates how to configure the OAuth strategy with the necessary URLs and credentials, and how to handle the authenticated user's profile.

const passport = require('passport');
const OAuthStrategy = require('passport-oauth1').Strategy;

passport.use(new OAuthStrategy({
    requestTokenURL: 'https://www.example.com/oauth/request_token',
    accessTokenURL: 'https://www.example.com/oauth/access_token',
    userAuthorizationURL: 'https://www.example.com/oauth/authorize',
    consumerKey: 'your-consumer-key',
    consumerSecret: 'your-consumer-secret',
    callbackURL: 'https://www.example.com/auth/example/callback'
  },
  function(token, tokenSecret, profile, done) {
    User.findOrCreate({ exampleId: profile.id }, function (err, user) {
      return done(err, user);
    });
  }
));

Token Handling

This feature demonstrates how to handle and store OAuth tokens. The code sample shows how to save the token and tokenSecret for later use, which is essential for making authenticated requests on behalf of the user.

passport.use(new OAuthStrategy({
    requestTokenURL: 'https://www.example.com/oauth/request_token',
    accessTokenURL: 'https://www.example.com/oauth/access_token',
    userAuthorizationURL: 'https://www.example.com/oauth/authorize',
    consumerKey: 'your-consumer-key',
    consumerSecret: 'your-consumer-secret',
    callbackURL: 'https://www.example.com/auth/example/callback'
  },
  function(token, tokenSecret, profile, done) {
    // Store the token and tokenSecret for later use
    saveToken(token, tokenSecret);
    User.findOrCreate({ exampleId: profile.id }, function (err, user) {
      return done(err, user);
    });
  }
));

function saveToken(token, tokenSecret) {
  // Save the token and tokenSecret to your database or session
  console.log('Token:', token);
  console.log('Token Secret:', tokenSecret);
}

Other packages similar to passport-oauth1

Keywords

FAQs

Package last updated on 01 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc